package com.j2eefast.pm.service;


import com.j2eefast.pm.entity.sysCompanyEntity;
import com.j2eefast.pm.mapper.sysCompanyMapper;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 物业公司Service接口
 * @author: paradisehere
 * @date 2020-05-23 11:15
 */
@Service
public class sysCompanyService extends ServiceImpl<sysCompanyMapper,sysCompanyEntity> {

	@Resource
	private sysCompanyMapper sysCompanyMapper;

	/**
	 * 页面分页查询
     */
	public PageUtil findPage(Map<String, Object> params) {
		QueryWrapper<sysCompanyEntity> r = new QueryWrapper<sysCompanyEntity>();
                        String name = (String) params.get("name");
                    r.like(ToolUtil.isNotEmpty(name), "name", name);
                        
                      String alias = (String) params.get("alias");
                    r.eq(ToolUtil.isNotEmpty(alias), "alias", alias);
        
                      String legalPerson = (String) params.get("legalPerson");
                    r.eq(ToolUtil.isNotEmpty(legalPerson), "legal_person", legalPerson);
        
                      String legalTel = (String) params.get("legalTel");
                    r.eq(ToolUtil.isNotEmpty(legalTel), "legal_tel", legalTel);
        
                      String bizLicenseNo = (String) params.get("bizLicenseNo");
                    r.eq(ToolUtil.isNotEmpty(bizLicenseNo), "biz_license_no", bizLicenseNo);
        
                      String bizLicensePhoto = (String) params.get("bizLicensePhoto");
                    r.eq(ToolUtil.isNotEmpty(bizLicensePhoto), "biz_license_photo", bizLicensePhoto);
        
                      String adminId = (String) params.get("adminId");
                    r.eq(ToolUtil.isNotEmpty(adminId), "admin_id", adminId);
        
                      String adminName = (String) params.get("adminName");
                    r.like(ToolUtil.isNotEmpty(adminName), "admin_name", adminName);
                        
                      String status = (String) params.get("status");
                    r.eq(ToolUtil.isNotEmpty(status), "status", status);
        
                                  String image = (String) params.get("image");
                    r.eq(ToolUtil.isNotEmpty(image), "image", image);
        
                      String introduce = (String) params.get("introduce");
                    r.eq(ToolUtil.isNotEmpty(introduce), "introduce", introduce);
        
                      String pwsUrl = (String) params.get("pwsUrl");
                    r.eq(ToolUtil.isNotEmpty(pwsUrl), "pws_url", pwsUrl);
        
                      String pwsId = (String) params.get("pwsId");
                    r.eq(ToolUtil.isNotEmpty(pwsId), "pws_id", pwsId);
        
                      String appid = (String) params.get("appid");
                    r.eq(ToolUtil.isNotEmpty(appid), "appid", appid);
        
                      String appSecret = (String) params.get("appSecret");
                    r.eq(ToolUtil.isNotEmpty(appSecret), "app_secret", appSecret);
        
                      		Page<sysCompanyEntity> page = this.baseMapper.selectPage(new Query<sysCompanyEntity>(params).getPage(), r);
		return new PageUtil(page);
    }

	/**
     * 批量删除
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean deletesysCompanyByIds(Long[] ids) {
		return this.removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
	public boolean deletesysCompanyById(Long id) {
		return this.removeById(id);
	}

	/**
     * 保存
     */
	public boolean savesysCompany(sysCompanyEntity sysCompany){
        return this.save(sysCompany);
    }

	/**
     * 修改根居ID
     */
	public boolean updatesysCompanyById(sysCompanyEntity sysCompany) {
		return this.updateById(sysCompany);
	}

	/**
     * 根居ID获取对象
     */
	public sysCompanyEntity getsysCompanyById(Long id){
		return this.getById(id);
	}
}
